
<?php echo $this->fetch('header.php'); ?>
<script type="text/javascript" src="core/scripts/jquery.lightbox.js"></script>
<link rel="stylesheet" type="text/css" href="core/styles/jquery.lightbox.css" />
<div class="layout">
	<?php if ($this->_var['article']): ?>
	<form action="?action=content&do=article_delete" method="post" id="article_form">
	<table cellspacing="0" cellpadding="0" width="100%" class="table">
		<thead>
		<tr>
		<th align="center" width="5%">&nbsp;</th>
		<th align="left"  width="53%">标题</td>
 		<th width="15%">发布时间</td>
 		<th width="15%">是否HTML</td>
		<th width="12%" nowrap>操作</td>
		</tr>
		</thead>
		<tbody>
		<?php $_from=$this->_var['article']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('$attrs[key]', '$attrs[item]');if (count($_from)):
    foreach ($_from AS $this->_var['article_0_51594800_1333199220']):
?>
		<tr>
		<td style="height:30px;" align="center" ><input type="checkbox" class="checkbox" name="article_id[]" value="<?php echo $this->_var['article_0_51594800_1333199220']['id']; ?>" /></td>
		<td>
		<?php if ($this->_var['article_0_51594800_1333199220']['category_name']): ?>
		<a href="?action=content&do=article&category_id=<?php echo $this->_var['article_0_51594800_1333199220']['category_id']; ?>" style="font-weight:bold;color:#F5D58D">[<?php echo $this->_var['article_0_51594800_1333199220']['category_name']; ?>]</a>&nbsp;
		<?php endif; ?>
		<a href="?action=content&do=article_edit&article_id=<?php echo $this->_var['article_0_51594800_1333199220']['id']; ?>"><?php echo $this->_var['article_0_51594800_1333199220']['title']; ?></a>

		<?php if ($this->_var['article_0_51594800_1333199220']['comment_count']): ?>
		(<a href="?action=content&do=comment&article_id=<?php echo $this->_var['article_0_51594800_1333199220']['id']; ?>" style="color:#B5D53B">评论<?php echo $this->_var['article_0_51594800_1333199220']['comment_count']; ?>条</a>)
		<?php endif; ?>

		<?php if ($this->_var['article_0_51594800_1333199220']['is_best'] == 1): ?>
			<b style="color:#B5D53B">[推荐]</b>
		<?php endif; ?>
		<?php if ($this->_var['article_0_51594800_1333199220']['is_comment'] == 0): ?>
			<b style="color:#FE8217">[评论已关闭]</b>
		<?php endif; ?>

		<?php if ($this->_var['article_0_51594800_1333199220']['image']): ?>
			<a href="<?php echo $this->_var['article_0_51594800_1333199220']['image']; ?>" target="_blank" class="lightbox"><img src="<?php echo $this->_var['article_0_51594800_1333199220']['image']; ?>" alt="" align="absmiddle" style="width:22px;height:22px;border:1px solid #333;padding:1px"/></a>
		<?php endif; ?>
		</td>


		<td align="center" style="color:#666" nowrap><?php echo $this->_var['article_0_51594800_1333199220']['time']; ?></td>
		<td align="center" style="color:#666" nowrap>
		<?php if ($this->_var['article_0_51594800_1333199220']['is_html'] == 1): ?>
		已生成
		<?php else: ?>
		未生成
		<?php endif; ?>
		
		</td>
		<td align="center" style="color:#666" nowrap>
		<a href="<?php echo $this->_var['article_0_51594800_1333199220']['url']; ?>" target="_blank" class="button">预览</a>
		<a href="?action=content&do=article_edit&article_id=<?php echo $this->_var['article_0_51594800_1333199220']['id']; ?>" class="button">编辑</a>
		</td>
		</tr>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();?>
		</tbody>
		<tfoot>
		<tr>
		<td height="30" align="center"><input type="checkbox" onclick="check_all(this)" /></td>
		<td colspan="4">
		<div style="float:right;margin:8px;"><?php echo $this->fetch('pager.php'); ?></div>
		<a href="javascript:;" onclick="html_article()" class="button">批量生成</a> <a href="javascript:;" onclick="del()" class="button">批量删除</a>
			<input type="text" class="input" id="search_keyword" />
	<a href="javascript:Search()"  class="button">搜索</a>
		</td>
		</tr>
		</tfoot>
	</table>
	</form>
	<?php else: ?>
	<div style="line-height:50px;text-align:center;">暂无数据</div>
	<?php endif; ?>

</div>
<div style="text-align:right">
<!--<a class="button" href="?action=content&do=clear" onclick="return confirm('确定要操作吗？')">清理全部数据</a>-->
<a class="button" href="?action=content&do=article_add<?php if ($_GET['category_id']): ?>&category_id=<?php echo $_GET['category_id']; ?><?php endif; ?>">发布文章</a>
</div>
<script type="text/javascript">
$(function(){
	$('.lightbox').lightBox();
});
function Search(){
var keyword=$("#search_keyword").val();
	if($.trim(keyword)==''){
		alert('关键字不能为空');
		$("#search_keyword").focus();
		return;
	}
	keyword=keyword.replace(/\'/gi,"");
	keyword=keyword.replace(/\"/gi,"");
	keyword=keyword.replace(/\?/gi,"");
	keyword=keyword.replace(/\%/gi,"");
	keyword=keyword.replace(/\./gi,"");
	keyword=keyword.replace(/\*/gi,"");
	window.location.href="?action=content&do=article<?php if ($_GET['category_id']): ?>&category_id=<?php echo $_GET['category_id']; ?><?php endif; ?>&keyword="+encodeURI(keyword);
}
function del(){
	var status=false;
	$('.checkbox').each(function(){
		if($(this).attr('checked')){
			status=true;
		}
	});
	if(!status){
		alert('至少选择一项');
		return false;
	}
	$('#article_form').attr('action','?action=content&do=article_delete');
	$('#article_form').submit();
}
function html_article(){
	var status=false;
	$('.checkbox').each(function(){
		if($(this).attr('checked')){
			status=true;
		}
	});
	if(!status){
		alert('至少选择一项');
		return false;
	}
	if(confirm('确定要操作吗？')){
		$('#article_form').attr('action','?action=content&do=html');
		$('#article_form').submit();
	}
}
</script>